package mt.Q1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] positions = new int[n];

        for (int i = 0; i < n; i++) {
            positions[i] = scanner.nextInt();
        }

        // 二分查找的边界
        int left = 1;
        int right = positions[n - 1] - positions[0] + 1; // 最小区间和最大区间
        int result = right;

        while (left <= right) {
            int mid = left + (right - left) / 2;
            if (canPlantAtLeastKTrees(positions, n, k, mid)) {
                result = mid;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }

        System.out.println(result);
    }

    private static boolean canPlantAtLeastKTrees(int[] positions, int n, int k, int length) {
        long totalTrees = 0;
        int lastEnd = -1;

        for (int i = 0; i < n; i++) {
            int start = positions[i];
            int end = start + length - 1;

            if (start <= lastEnd) {
                start = lastEnd + 1; // 处理重叠区域
            }

            if (start <= end) {
                totalTrees += (end - start + 1);
                lastEnd = end;
            }

            if (totalTrees >= k) {
                return true;
            }
        }

        return totalTrees >= k;
    }
}
